import logging

import pymysql

# 创建连接
conn = pymysql.connect(host="211.103.136.244", port=7068, user="student", password="KDTX_student_202304",
                       database="huike", charset="utf8")
# 创建游标
cursor = conn.cursor()
# 执行sql语句
try:
    insert_sql="insert into tb_course (name) values ('小葵花妈妈开课了')"
    select_sql = "select * from tb_course where name='小葵花妈妈开课了'"
    cursor.execute(insert_sql)
    cursor.execute(select_sql)
    logging.info(cursor.fetchone())
    conn.commit()
except Exception as e:
    conn.rollback()
# 关闭游标
cursor.close()
# 关闭连接
conn.close()
